package com.ficus.road.maintain.core.model.zh.roadice;

import com.ficus.road.maintain.core.model.RoadIce;
import lombok.Data;

/**
 * @author xiawen yang
 * @date 2022/1/25 下午7:22
 */
@Data
public class RoadIceZH {
    /**
     * 设备编号
     */
    private String deviceid;
    /**
     * 设备名称
     */
    private String devicename;
    /**
     * 时间
     */
    private String datatime;
    /**
     * 温度
     */
    private String runningstate;
    /**
     * 理论结冰温度
     */
    private String runningstate2;
    /**
     * 积水高度
     */
    private String runningstate3;
    /**
     * 盐度
     */
    private String runningstate4;
    /**
     * 路面状态, 0干燥1有水
     */
    private String runningstate5;
    /**
     * 结冰厚度
     */
    private String runningstate6;
    /**
     * 积雪厚度
     */
    private String runningstate7;
    /**
     * 结冰概率
     */
    private String runningstate8;
    /**
     * 是否正常, 0正常 1报警
     */
    private String runningstate9;
    /**
     * 经度
     */
    private String lon;
    /**
     * 纬度
     */
    private String lat;

    public RoadIce convert2RoadIce(RoadIceZH roadIceZH, String time, String updateTime) {
        RoadIce roadIce = RoadIce.builder().deviceId(roadIceZH.getDeviceid()).deviceName(roadIceZH.getDevicename())
                .time(time)
                .updateTime(updateTime)
                .temperature(roadIceZH.getRunningstate())
                .iceTheory(roadIceZH.getRunningstate2())
                .stagnant(roadIceZH.getRunningstate3())
                .salinity(roadIceZH.getRunningstate4())
                .roadStatus(roadIceZH.getRunningstate5()==null?"干燥":roadIceZH.getRunningstate5().equals("0") ? "干燥" : "有水")
                .iceDepth(roadIceZH.getRunningstate6())
                .snow(roadIceZH.getRunningstate7())
                .iceProbability(roadIceZH.getRunningstate8())
                .status(roadIceZH.getRunningstate9()==null?"0":roadIceZH.getRunningstate9())
                .alertStatus(roadIceZH.getRunningstate9()==null?"正常":roadIceZH.getRunningstate9().equals("0") ? "正常" : "报警")
//                .lgt(roadIceZH.getLon().substring(0, roadIceZH.getLon().indexOf("\\") == -1 ? roadIceZH.getLon().length() : roadIceZH.getLon().indexOf("\\")))
                .lgt(roadIceZH.getLon().trim())
                .lat(roadIceZH.getLat().trim())
                .build();
        return roadIce;
    }
}
